package com.bangyu.monitor.modular.system.entity;

import com.bangyu.monitor.core.util.FormatUtil;
import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @Auther: zhangxue
 * @Date: 19/5/28 21:52
 * @Description:
 */
@Data
public class MonitorInfoDetail {

    private String startTime = "";
    private String endTime = "";
    private String customerName = "";
    private String bridgeName = "";//桥梁名称
    private String property = "";//桥梁属性
    private String stakeCode = "";//桩号
    private String line = "";//线路
    private String span = "";//跨径
    private Float threshold;//阈值
    private Integer heavyCount = 0;//重型荷载次数
    private String heavyRate;//重型荷载占比
    private Integer lightCount = 0;//轻型荷载数据
    private String lightRate;//轻型荷载占比
    private Integer extremityWarnCount = 0;//极限预警次数
    private Integer extremityAlarmCount = 0;//极限报警次数
    private Integer emergencyWarnCount = 0;//突发预警次数
    private Integer emergencyAlarmCount = 0;//突发报警次数



    //计算重型荷载与轻型荷载的占比
    public void cacuPayloadRate(){
        if(heavyCount != null && heavyCount != 0 && lightCount != null && lightCount != 0){
            BigDecimal heavyCountDec = new BigDecimal(heavyCount);
            BigDecimal lightCountDec = new BigDecimal(lightCount);

            BigDecimal heavyRateDec = heavyCountDec.divide(heavyCountDec.add(lightCountDec),4,RoundingMode.CEILING);
            BigDecimal lightRateDec = BigDecimal.ONE.subtract(heavyCountDec);

            setHeavyRate(FormatUtil.percentFormat(heavyRateDec));
            setLightRate(FormatUtil.percentFormat(lightRateDec));
        }
    }



}
